home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 7 / Example 7.4 / skinnedMesh.h < prev   
Encoding:
C/C++ Source or Header  |  2006-07-27  |  1.1 KB  |  49 lines

  1. #ifndef SKINNED_MESH
  2. #define SKINNED_MESH
  3.  
  4. #include <windows.h>
  5. #include <d3dx9.h>
  6. #include <string>
  7. #include <vector>
  8. #include "debug.h"
  9.  
  10. struct BONE: public D3DXFRAME
  11. {
  12.     D3DXMATRIX CombinedTransformationMatrix;
  13. };
  14.  
  15. struct BONEMESH: public D3DXMESHCONTAINER
  16. {
  17.     ID3DXMesh* OriginalMesh;
  18.     std::vector<D3DMATERIAL9> materials;
  19.     std::vector<IDirect3DTexture9*> textures;
  20.  
  21.     DWORD NumAttributeGroups;
  22.     D3DXATTRIBUTERANGE* attributeTable;
  23.     D3DXMATRIX** boneMatrixPtrs;
  24.     D3DXMATRIX* boneOffsetMatrices;
  25.     D3DXMATRIX* currentBoneMatrices;
  26. };
  27.  
  28. class SKINNEDMESH
  29. {
  30.     public:
  31.         SKINNEDMESH();
  32.         ~SKINNEDMESH();
  33.         void Load(char fileName[], IDirect3DDevice9 *Dev);
  34.         void Render(BONE *bone);
  35.         void SetPose(D3DXMATRIX world, ID3DXAnimationController* animControl, float time);
  36.         void SetAnimation(char name[]);
  37.         std::vector<std::string> GetAnimations();
  38.         BONE* FindBone(char name[]);
  39.  
  40.     private:
  41.         void UpdateMatrices(BONE* bone, D3DXMATRIX *parentMatrix);
  42.         void SetupBoneMatrixPointers(BONE *bone);
  43.  
  44.         IDirect3DDevice9 *m_pDevice;
  45.         D3DXFRAME *m_pRootBone;
  46.         ID3DXAnimationController *m_pAnimControl;
  47. };
  48.  
  49. #endif